using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using DevComponents.DotNetBar;

namespace Pg.BioMedics.RatObserver.Gui.Controls
{
    public partial class InputForm : Office2007Form
    {
        #region Constructors

        public InputForm()
        {
            InitializeComponent();
        }

        #endregion

        #region Properties

        public string Value
        {
            get
            {
                return entryTextBox.Value.ToString();
            }
        }

        #endregion

        #region Event handlers

        private void entryTextBox_TextChanged(object sender, EventArgs e)
        {
            okButton.Enabled = (entryTextBox.ValueObject != null);
        }

        private void InputForm_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                DialogResult = DialogResult.Cancel;
                Close();
            }
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        #endregion                               

        #region Overriden methods

        public DialogResult ShowDialog(string initialValue)
        {
            Text = "Edit entry";
            okButton.Text = "Update";

            int value = 0;
            if (Int32.TryParse(initialValue, out value))
                entryTextBox.Value = value;
            else
                entryTextBox.Value = 0;

            return ShowDialog();
        }

        #endregion
    }
}